1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Concatenating Date and Time Field in SQL

Discussion in 'Software Development' started by grimlockpdp, Jan 25, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. grimlockpdp

    grimlockpdp Thread Starter

    Joined:
    Sep 22, 2009
    Messages:
    26
    Hello, I need help with the following:


    I have a field (called Date_Time) which displays for example 1/31/2005 12:00:00 AM. I would like to run a query that converts that value to '200501' in a created field.


    I tried the following below but I keep having problems.

    select Account_Number, Date_Time,
    concat(year(Date_Time), month(Date_Time)) as Date_Time_Modified
    from table
    where Account_Number = xxxx



    Any insight into this would be greatly appreciated. Thank you.




     
  2. grimlockpdp

    grimlockpdp Thread Starter

    Joined:
    Sep 22, 2009
    Messages:
    26
    Just wanted to add some more examples:

    Account_Number: Integer Type
    Date_Time: Date Type
    Date_Time: Modified: Character Type

    Account_Number Date_Time Date_Time_Modified
    3246 1/31/2005 12:00:00 AM 200501
    4920 11/30/2008 12:00:00 AM 200811
    5932 6/30/2011 12:00:00 AM 201106
    ... ... ....
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1038057