Solved

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

Posted on 2013-01-07
11
439 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
insert wont work in SQL 14 21
Increment column based of a FK 8 22
T-SQL: New to using transactions 9 28
SQL Count issue 24 15
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

773 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