Solved

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

Posted on 2008-06-11
9
194 Views
Last Modified: 2013-11-27
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

0
Comment
Question by:syedasimmeesaq
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21764856
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
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764873
but how do I update the table? the above query will give me just the view and would not update the records

Thanks
0
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21764875
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
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764905
whats that? I have no idea how to use the above suggestion
Thanks
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Accepted Solution

by:
NIMTUG_Simon earned 500 total points
ID: 21764916
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
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764947
shouldn't it be

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

????????????????
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 21764951
ok no worries posted before looking at your second comment. Basically the same thing...I will try it now.
Thanks
0
 
LVL 3

Expert Comment

by:NIMTUG_Simon
ID: 21764961
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
 
LVL 9

Author Closing Comment

by:syedasimmeesaq
ID: 31466394
thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now