Avatar of Ernesto
Ernesto
Flag for Mexico asked on

get today date format dd/mm/yyyy sql visual.net

Hi, all
is any way to achive

Dim nusa1 As String = "update cheque set fechat=today format (dd/mm/yyyy) where id='" & CustomerId & "'"
            Dim cmd11 As New OleDbCommand(nusa1, cn)
            cmd11.ExecuteScalar()

I need retrive the today date format dd/mm/yyyy
tsm
Microsoft SQL ServerVisual Basic.NETSQL

Avatar of undefined
Last Comment
Ernesto

8/22/2022 - Mon
Haver Ramirez

for sql

DECLARE  @dt DATETIME
set @dt = '2013-01-01'
select CONVERT(VARCHAR,@dt, 103) 

Open in new window


for basic

http://msdn.microsoft.com/en-us/library/az4se3k1%28v=vs.71%29.aspx
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Ernesto

ASKER
i need it to put in  vb.net code
tsm
deighton

what is the data type of field fechat?

Are you wanting to retrieve data from the table or update the table?

The code you showed us updates the table.  I believe there is no select so it retrieves no data.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Ernesto

ASKER
is varchar
tsm
update the table with the todays date

yes it update the table
Ernesto

ASKER
but i need to update with the system date  
tsm
Haver Ramirez

save in a variable,

Dim dtNow as Datetime
Dim nusa1 As String = "update cheque set fechat= getdate() where id='" & CustomerId & "'"
Dim cmd11 As New OleDbCommand(nusa1, cn)
dtNow = Cast(cmd11.ExecuteScalar() as datetime)
' later format you datetime value
dim strFormat as string 
strFormat = Format(dtNow,"dd/MM/yy")

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Nasir Razzaq

Change this

Dim nusa1 As String = "update cheque set fechat=today format (dd/mm/yyyy) where id='" & CustomerId & "'"

to

Dim nusa1 As String = "update cheque set fechat='" & Today.ToString("dd/mm/yyyy") & "' where id='" & CustomerId & "'"
Ernesto

ASKER
codecruise
almost
give me the date as 07/00/2013
when need to be  07/01/2013

tsm
almos please!!!
ASKER CERTIFIED SOLUTION
Nasir Razzaq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ernesto

ASKER
ok need to be  ("dd/MM/yyyy")
tsm
regards,
you save me!!
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Ernesto

ASKER
tsm all