• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1449
  • Last Modified:

Input a hardcoded datetime value through SQL

Hello Experts,

Here's what I want to do.

Insert into Table (myDate)
Values ('11/16/2006 21:37')

However, it doesn't want to convert a "string" to a datetime value.
What code would I write to correct this?

Thanks!
GRCHELPDESK
0
GRCHELPDESK
Asked:
GRCHELPDESK
  • 3
1 Solution
 
HillwaaaCommented:
try:

Insert into Table (myDate)
Values (convert(datetime,'11/16/2006 21:37')

or

Insert into Table (myDate)
Values (convert(datetime,'11/16/2006 21:37',101)  
0
 
HillwaaaCommented:
sorry - missing braces:

Insert into Table (myDate)
Values (convert(datetime,'11/16/2006 21:37'))

or

Insert into Table (myDate)
Values (convert(datetime,'11/16/2006 21:37',101))
0
 
GRCHELPDESKAuthor Commented:
Hey Hillwaaa,

That worked perfectly, thanks!
0
 
HillwaaaCommented:
No worries!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now