date string..put it according to month, day and year

I have three field

Date                   Month               day            year
1-30-2008
12-11-2006
1-15-2007

my other fields have no records. Just the Date field has records. How would I divide the date so it updates the corresponding fields accordingly
something like this

Date                   Month               day            year
1-30-2008             1                     30            2008
12-11-2006          12                    11            2006
1-15-2007             1                     15            2007

Thanks

LVL 9
syedasimmeesaqAsked:
Who is Participating?
 
NIMTUG_SimonCommented:
ONly got Access 2003.. not sure if later version support calculated fields

You could populate all your dates and then run the following query which will update the other columns

UPDATE Table1 SET Table1.[Day] = Day([Date]), Table1.[Month] = Month([Date]), Table1.[Year] = Year([Date]);
0
 
NIMTUG_SimonCommented:
Select [Date], Month([Date]) as [Month], Day(]Date]) as [Day], Year([Date]) as [Year] from Table

You can add these as calculated fields in your table.
0
 
syedasimmeesaqAuthor Commented:
but how do I update the table? the above query will give me just the view and would not update the records

Thanks
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
NIMTUG_SimonCommented:
Sry was thinking SQL Server

Might still work if not use

DatePart

Usage: DatePart(interval, date)

Interval may be set to:
yyyy for year
q for quarter
m for month
y for day of year
d for day
w for weekday
ww for week
h for hour
n for minute
s for second

Returns: Interval part of date.
0
 
syedasimmeesaqAuthor Commented:
whats that? I have no idea how to use the above suggestion
Thanks
0
 
syedasimmeesaqAuthor Commented:
shouldn't it be

update table set month = month(date), day = day(date), year = year(date);

????????????????
0
 
syedasimmeesaqAuthor Commented:
ok no worries posted before looking at your second comment. Basically the same thing...I will try it now.
Thanks
0
 
NIMTUG_SimonCommented:
It doesn't matter about the order and the Table1 prefix is optional. You should alway use [ ] around column names that are the same as in-built Access functions.
0
 
syedasimmeesaqAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.