?
Solved

ms sql query string syntax for formatting date functions?

Posted on 2003-03-18
4
Medium Priority
?
265 Views
Last Modified: 2008-02-01
hello!

I am looking for a way, to transform the date format in the database into a unix timestamp while querying. In the database, the format is DD.MM.YY and I am looking for a function similar to "UNIX_TIMESTAMP()" in MySQL in MS SQL. Is there something like that?

Thanks for any help!

regards,
Christoph
0
Comment
Question by:emc_
[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
  • 2
4 Comments
 
LVL 9

Expert Comment

by:xenon_je
ID: 8158511
Can you explain what UNIX_TIMESTAMP() does in MySQL?
IN MSSQL there is the timestamp datatype, read about it, maybe is what you need.
gl
0
 
LVL 43

Accepted Solution

by:
Eugene Z earned 225 total points
ID: 8158555
select getdate()
-- '2003-03-18 07:20:00'

select datediff(ss,'1970-01-01 02:00:00.000','2003-03-18 07:20:00')

--- "UNIX_TIMESTAMP()" result  1047964800
0
 

Author Comment

by:emc_
ID: 8159066
ok, i tried your string, Eugene, which works fine. but how can i put in a column content? i tried this:

"select taskID, userID, datediff(ss,'1970-01-01 02:00:00.000','taskDate') from tblTasks;"

but it doesn't work. do you know why? thanks for hints!


regards,
christoph
0
 
LVL 43

Expert Comment

by:Eugene Z
ID: 8159142
select taskID, userID, datediff(ss,'1970-01-01 02:00:00.000',taskDate) from tblTasks;"
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
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 shrink a transaction log file down to a reasonable size.
Suggested Courses

764 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