replace year in field date

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

replace year in field date

Post by sal21 »

How to replace the year in field DATE, without change the dd/mm, based a MyYear var Integer
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: replace year in field date

Post by HansV »

Code: Select all

SQL = "UPDATE [MYTABLE] SET [DATE] = DateSerial(" & MyYear & ",Month([DATE]),Day([DATE]))"
Last edited by HansV on 15 Jul 2020, 21:28, edited 1 time in total.
Reason: to correct mistake
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: replace year in field date

Post by sal21 »

HansV wrote:
15 Jul 2020, 19:01

Code: Select all

SQL = "UPDATE [MYTABLE] SET [DATE] = DateSerial(" & MyYear & ",Month([DATE]),Day([DATE])"
Peraphs, One closed parenthesis to the last character in SQL?

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: replace year in field date

Post by HansV »

Sorry, there should be two closing parentheses. I will correct my previous reply.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: replace year in field date

Post by sal21 »

HansV wrote:
15 Jul 2020, 21:28
Sorry, there should be two closing parentheses. I will correct my previous reply.
O no problem Bro!