Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Input a hardcoded datetime value through SQL

Posted on 2006-11-16
4
Medium Priority
?
1,399 Views
Last Modified: 2006-11-18
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
Comment
Question by:GRCHELPDESK
  • 3
4 Comments
 
LVL 16

Expert Comment

by:Hillwaaa
ID: 17961412
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
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 2000 total points
ID: 17961416
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
 
LVL 2

Author Comment

by:GRCHELPDESK
ID: 17961436
Hey Hillwaaa,

That worked perfectly, thanks!
0
 
LVL 16

Expert Comment

by:Hillwaaa
ID: 17961444
No worries!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

886 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