Solved

Input a hardcoded datetime value through SQL

Posted on 2006-11-16
4
1,063 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 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now