Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ms sql query string syntax for formatting date functions?

Posted on 2003-03-18
4
Medium Priority
?
274 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_
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

564 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