Solved

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

Posted on 2008-06-11
9
199 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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.​
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

912 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

20 Experts available now in Live!

Get 1:1 Help Now