Solved

Input a hardcoded datetime value through SQL

Posted on 2006-11-16
4
1,219 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
[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
  • 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 500 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

752 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