I've just been trying to do this. I looked on Google and it seems to
be a common problem with no obvious solution. I've seen various
solutions which don't seem exactly elegant, so I figured I'd post the
solution I came up with. It's effectively a single line solution,
albeit with various embedded calls. It makes an adjustment for the
local timezone too!
DECLARE @.time_t INT
SET @.time_t = 1090834321 /* 10:32am, July 26th 2004 BST */
DECLARE @.timestamp DATETIME
SET @.timestamp = dateadd (ss, datediff (ss, GetUTCDate(), GetDate()),
dateadd (ss, @.time_t, '19700101'))
PRINT @.timestamp
Hope that helps. If there's a problem with it, let me know!
andytHi Andy,
I have received a data file and it has julian dates. How Do I convert them
to normal dates? I tried this code and replaced the variable with the date I
received, and All it did was give me the same date with different times.
Any ideas? What does the hardcoded '1970-01-01' do?
Thanks
Noma-Gcina
nmtshontshi@.deloitte.com
"Andy Turner" wrote:
> I've just been trying to do this. I looked on Google and it seems to
> be a common problem with no obvious solution. I've seen various
> solutions which don't seem exactly elegant, so I figured I'd post the
> solution I came up with. It's effectively a single line solution,
> albeit with various embedded calls. It makes an adjustment for the
> local timezone too!
>
> DECLARE @.time_t INT
> SET @.time_t = 1090834321 /* 10:32am, July 26th 2004 BST */
> DECLARE @.timestamp DATETIME
> SET @.timestamp = dateadd (ss, datediff (ss, GetUTCDate(), GetDate()),
> dateadd (ss, @.time_t, '19700101'))
> PRINT @.timestamp
>
> Hope that helps. If there's a problem with it, let me know!
>
> andyt
>|||The Unix timestamp value represents the number of seconds since 1970-01-01.
You can convert it like this:
DECLARE @.ts INTEGER
SET @.ts = 1098230400
SELECT DATEADD(SECOND,@.ts,'19700101')
(This isn't a Julian Date BTW)
David Portas
SQL Server MVP
--
Showing posts with label tobe. Show all posts
Showing posts with label tobe. Show all posts
Tuesday, March 27, 2012
Converting C++ Unix time_t Julian date to SQL date
I've just been trying to do this. I looked on Google and it seems to
be a common problem with no obvious solution. I've seen various
solutions which don't seem exactly elegant, so I figured I'd post the
solution I came up with. It's effectively a single line solution,
albeit with various embedded calls. It makes an adjustment for the
local timezone too!
DECLARE @.time_t INT
SET @.time_t = 1090834321/* 10:32am, July 26th 2004 BST */
DECLARE @.timestamp DATETIME
SET @.timestamp = dateadd (ss, datediff (ss, GetUTCDate(), GetDate()),
dateadd (ss, @.time_t, '19700101'))
PRINT @.timestamp
Hope that helps. If there's a problem with it, let me know!
andyt
Hi Andy,
I have received a data file and it has julian dates. How Do I convert them
to normal dates? I tried this code and replaced the variable with the date I
received, and All it did was give me the same date with different times.
Any ideas? What does the hardcoded '1970-01-01' do?
Thanks
Noma-Gcina
nmtshontshi@.deloitte.com
"Andy Turner" wrote:
> I've just been trying to do this. I looked on Google and it seems to
> be a common problem with no obvious solution. I've seen various
> solutions which don't seem exactly elegant, so I figured I'd post the
> solution I came up with. It's effectively a single line solution,
> albeit with various embedded calls. It makes an adjustment for the
> local timezone too!
>
> DECLARE @.time_t INT
> SET @.time_t = 1090834321/* 10:32am, July 26th 2004 BST */
> DECLARE @.timestamp DATETIME
> SET @.timestamp = dateadd (ss, datediff (ss, GetUTCDate(), GetDate()),
> dateadd (ss, @.time_t, '19700101'))
> PRINT @.timestamp
>
> Hope that helps. If there's a problem with it, let me know!
>
> andyt
>
|||The Unix timestamp value represents the number of seconds since 1970-01-01.
You can convert it like this:
DECLARE @.ts INTEGER
SET @.ts = 1098230400
SELECT DATEADD(SECOND,@.ts,'19700101')
(This isn't a Julian Date BTW)
David Portas
SQL Server MVP
be a common problem with no obvious solution. I've seen various
solutions which don't seem exactly elegant, so I figured I'd post the
solution I came up with. It's effectively a single line solution,
albeit with various embedded calls. It makes an adjustment for the
local timezone too!
DECLARE @.time_t INT
SET @.time_t = 1090834321/* 10:32am, July 26th 2004 BST */
DECLARE @.timestamp DATETIME
SET @.timestamp = dateadd (ss, datediff (ss, GetUTCDate(), GetDate()),
dateadd (ss, @.time_t, '19700101'))
PRINT @.timestamp
Hope that helps. If there's a problem with it, let me know!
andyt
Hi Andy,
I have received a data file and it has julian dates. How Do I convert them
to normal dates? I tried this code and replaced the variable with the date I
received, and All it did was give me the same date with different times.
Any ideas? What does the hardcoded '1970-01-01' do?
Thanks
Noma-Gcina
nmtshontshi@.deloitte.com
"Andy Turner" wrote:
> I've just been trying to do this. I looked on Google and it seems to
> be a common problem with no obvious solution. I've seen various
> solutions which don't seem exactly elegant, so I figured I'd post the
> solution I came up with. It's effectively a single line solution,
> albeit with various embedded calls. It makes an adjustment for the
> local timezone too!
>
> DECLARE @.time_t INT
> SET @.time_t = 1090834321/* 10:32am, July 26th 2004 BST */
> DECLARE @.timestamp DATETIME
> SET @.timestamp = dateadd (ss, datediff (ss, GetUTCDate(), GetDate()),
> dateadd (ss, @.time_t, '19700101'))
> PRINT @.timestamp
>
> Hope that helps. If there's a problem with it, let me know!
>
> andyt
>
|||The Unix timestamp value represents the number of seconds since 1970-01-01.
You can convert it like this:
DECLARE @.ts INTEGER
SET @.ts = 1098230400
SELECT DATEADD(SECOND,@.ts,'19700101')
(This isn't a Julian Date BTW)
David Portas
SQL Server MVP
Thursday, March 8, 2012
Convert SQL Data
I am looking for a way to convert SQL data to Access 2002 format. I want to
be able to view the data in access. Is there a way to connect to my SQL
server with access and be able to view and save the databases to the access
format. I want to be able to have a DBF copy of my access databases in the
event of a total failure.KMD,
There are a couple of ways to do this. 1) you can use Access to import your
SQL Server database into Access. This is probably the easiest way. 2)
Attach the SQL Server tables to your Access database. From there you can ru
n
queries that create new tables or just keep them attached and view them that
way.
Hope this helps.
Scott
"kmd" wrote:
> I am looking for a way to convert SQL data to Access 2002 format. I want
to
> be able to view the data in access. Is there a way to connect to my SQL
> server with access and be able to view and save the databases to the acces
s
> format. I want to be able to have a DBF copy of my access databases in th
e
> event of a total failure.
>
>
be able to view the data in access. Is there a way to connect to my SQL
server with access and be able to view and save the databases to the access
format. I want to be able to have a DBF copy of my access databases in the
event of a total failure.KMD,
There are a couple of ways to do this. 1) you can use Access to import your
SQL Server database into Access. This is probably the easiest way. 2)
Attach the SQL Server tables to your Access database. From there you can ru
n
queries that create new tables or just keep them attached and view them that
way.
Hope this helps.
Scott
"kmd" wrote:
> I am looking for a way to convert SQL data to Access 2002 format. I want
to
> be able to view the data in access. Is there a way to connect to my SQL
> server with access and be able to view and save the databases to the acces
s
> format. I want to be able to have a DBF copy of my access databases in th
e
> event of a total failure.
>
>
Convert SQL Data
I am looking for a way to convert SQL data to Access 2002 format. I want to
be able to view the data in access. Is there a way to connect to my SQL
server with access and be able to view and save the databases to the access
format. I want to be able to have a DBF copy of my access databases in the
event of a total failure.
KMD,
There are a couple of ways to do this. 1) you can use Access to import your
SQL Server database into Access. This is probably the easiest way. 2)
Attach the SQL Server tables to your Access database. From there you can run
queries that create new tables or just keep them attached and view them that
way.
Hope this helps.
Scott
"kmd" wrote:
> I am looking for a way to convert SQL data to Access 2002 format. I want to
> be able to view the data in access. Is there a way to connect to my SQL
> server with access and be able to view and save the databases to the access
> format. I want to be able to have a DBF copy of my access databases in the
> event of a total failure.
>
>
be able to view the data in access. Is there a way to connect to my SQL
server with access and be able to view and save the databases to the access
format. I want to be able to have a DBF copy of my access databases in the
event of a total failure.
KMD,
There are a couple of ways to do this. 1) you can use Access to import your
SQL Server database into Access. This is probably the easiest way. 2)
Attach the SQL Server tables to your Access database. From there you can run
queries that create new tables or just keep them attached and view them that
way.
Hope this helps.
Scott
"kmd" wrote:
> I am looking for a way to convert SQL data to Access 2002 format. I want to
> be able to view the data in access. Is there a way to connect to my SQL
> server with access and be able to view and save the databases to the access
> format. I want to be able to have a DBF copy of my access databases in the
> event of a total failure.
>
>
Subscribe to:
Posts (Atom)