Solved

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

Posted on 2013-01-07
11
434 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now