Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / May 2005

Tip: Looking for answers? Try searching our database.

How can I get access to put only the current year in a field?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Willem - 15 May 2005 16:13 GMT
Hi all,

I'm having problems forcing acces to put only the current year in a field of
each record of my database. At the moment I solved this by changing the
properties of the field as follows: "Format: yyyy" and "Default value:
=Date()", and this works just fine, but when I want to use this field in an
ASP page access returns it as a whole date again instead of only the year.
Any solutions to this?

TIA

Willem
Ed Warren - 15 May 2005 05:37 GMT
Store the field value as a date (much more useful than just a year).
Access the data through a query in Access e.g. qryYear:
FieldYear:Year([fielddate])
ASP will be happy to show the year.

Ed Warren

> Hi all,
>
[quoted text clipped - 8 lines]
>
> Willem
Willem - 15 May 2005 18:11 GMT
Hi Ed,

I think that's te best solution to my problem. I don't understand your
query-=instructions though.
In my case a simple query to show the number and the date fields of my
database would be:

SELECT [Dossiers].NUMMER, [Dossiers].REG_DAT FROM [Dossiers];

Dossiers is the table,

NUMMER is a numberfield autonumbered by access

REG_DAT is a datefield (as registration date) also autofilled by access

How do I go about to let this query show only the number and the year of the
field REG_DAT?

TIA

Willem

> Store the field value as a date (much more useful than just a year).
> Access the data through a query in Access e.g. qryYear:
[quoted text clipped - 15 lines]
>>
>> Willem
Randy Harris - 15 May 2005 19:09 GMT
> Hi Ed,
>
[quoted text clipped - 24 lines]
> >
> > Ed Warren

As Ed indicated in his post, you can use:
FieldYear:Year([fielddate])

So, your query would be:
SELECT [Dossiers].NUMMER, RegYear:Year(REG_DAT) FROM [Dossiers];

That way you will only get the year of the registration.
Willem - 15 May 2005 19:49 GMT
Hi Randy,

Sorry, but then Access comes with a syntax error in RegYear:Year(REG_DAT).

Regards,

Willem

>> Hi Ed,
>>
[quoted text clipped - 33 lines]
>
> That way you will only get the year of the registration.
Douglas J. Steele - 15 May 2005 19:54 GMT
While you'd type RegYear: Year(REG_DAT) into the graphical query builder
grid, the SQL that's generated is actually:

SELECT [Dossiers].NUMMER, Year(REG_DAT) AS RegYear FROM [Dossiers]

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi Randy,
>
[quoted text clipped - 41 lines]
>>
>> That way you will only get the year of the registration.
Willem - 15 May 2005 20:12 GMT
Hi Doug,

I wasn't aware of that, now it works fine, thanks!

Regards,

Willem

> While you'd type RegYear: Year(REG_DAT) into the graphical query builder
> grid, the SQL that's generated is actually:
[quoted text clipped - 48 lines]
>>>
>>> That way you will only get the year of the registration.
Rick Brandt - 15 May 2005 16:35 GMT
> Hi all,
>
[quoted text clipped - 8 lines]
>
> Willem

If you want a year then use a number field.  A Date field will always hold a
complete date (including time).

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Willem - 15 May 2005 18:05 GMT
Hi Rick,

I thought of that too, but then I can't make access to automatically enter
the year based on the systemdate.

Thanks anyway,

Regards,

Willem
>> Hi all,
>>
[quoted text clipped - 11 lines]
> If you want a year then use a number field.  A Date field will always hold
> a complete date (including time).
Rick Brandt - 15 May 2005 22:55 GMT
> Hi Rick,
>
> I thought of that too, but then I can't make access to automatically
> enter the year based on the systemdate.

Sure you can.  Default value of Year(Date()).

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.