MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 6th, 2013, 04:19 AM
mehow mehow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 mehow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 45 m 50 sec
Reputation Power: 0
Sql query - select * and apply dateadd to 2 columns

Hello.
I am a proper beginner in the world of sql, so i will be really thankful if someone can help me with my problem.
I am trying to display all columns from a table and apply some formatting(formula) to only 1 maybe 2 of them.
logic example:

apply: DATEADD(day,CURDATE/1440, '01/01/1988')

SELECT * and apply FROM tableONE

I hope this makes sense! Cheers

Reply With Quote
  #2  
Old March 6th, 2013, 05:38 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,375 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 7 h 30 m 23 sec
Reputation Power: 4140
Quote:
Originally Posted by mehow
I hope this makes sense! Cheers
nope, sorry, it doesn't

and it looks like you're not using mysql, so i've moved your thread to the MS SQL forum
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old March 6th, 2013, 05:44 AM
mehow mehow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 mehow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 45 m 50 sec
Reputation Power: 0
I have not designed the database I am working with. I am using 'Priority 15's database.

the conversion is done with this statement : DATEADD(day,CURDATE/1440, '01/01/1988')

I will try to explain this again.

example:
There is a table called TableOne
There are 3 columns in TableOne - NAMEA, CURDATE, NAMEB
NAMEA is VARCHAR(20)
CURDATE is BIGINT datatype ( value 13163040 represents 10/01/2013 )
NAMEB is VARCHAR(20)

Now, if I wanted to display all columns from TableOne so SELECT * FROM TableOne
But, if I wanted to apply this: DATEADD(day,CURDATE/1440, '01/01/1988') to column CURDATE and then display all columns - then how do i do that?

display result would be :
NAMEA, CURDATE, NAMEB
but CURDATE column ( all values ) are not 13163040 but dd/mm/yyyy

Reply With Quote
  #4  
Old March 6th, 2013, 06:09 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,375 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 7 h 30 m 23 sec
Reputation Power: 4140
Code:
SELECT namea
     , DATEADD(DAY,CURDATE/1440,'01/01/1988') AS curdate
     , nameb
  FROM TableOne

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Sql query - select * and apply dateadd to 2 columns

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap