Solved

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

Posted on 2013-01-07
11
443 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

734 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