Solved

Input a hardcoded datetime value through SQL

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

757 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

24 Experts available now in Live!

Get 1:1 Help Now