#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep 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
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,178
    Rep Power
    4274
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep 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
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,178
    Rep Power
    4274
    Code:
    SELECT namea
         , DATEADD(DAY,CURDATE/1440,'01/01/1988') AS curdate
         , nameb
      FROM TableOne
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo