Solved

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

Posted on 2013-01-07
11
440 Views
Last Modified: 2013-01-07
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
0
Comment
Question by:edo60
  • 6
  • 2
  • 2
  • +1
11 Comments
 
LVL 8

Expert Comment

by:Crashman
ID: 38751303
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
0
 

Author Comment

by:edo60
ID: 38751314
i need it to put in  vb.net code
tsm
0
 
LVL 18

Expert Comment

by:deighton
ID: 38751331
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.
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 

Author Comment

by:edo60
ID: 38751341
is varchar
tsm
update the table with the todays date

yes it update the table
0
 

Author Comment

by:edo60
ID: 38751357
but i need to update with the system date  
tsm
0
 
LVL 8

Expert Comment

by:Crashman
ID: 38751386
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

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38751461
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 & "'"
0
 

Author Comment

by:edo60
ID: 38751496
codecruise
almost
give me the date as 07/00/2013
when need to be  07/01/2013

tsm
almos please!!!
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38751513
oops. use

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

Author Comment

by:edo60
ID: 38751514
ok need to be  ("dd/MM/yyyy")
tsm
regards,
you save me!!
0
 

Author Closing Comment

by:edo60
ID: 38751518
tsm all
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question