Avatar of Member_2_4286571
Member_2_4286571
 asked on

Search query only by year.

Hi guys,

I need to select highest number based on specific year.

Select max(num) from SomeTable where Date like '%2012%'

now this is not good since month 12 and day 20 in 2013 year will also respond to this query.

my date format is ddMMyyyy.

Any suggestions?
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
Member_2_4286571

8/22/2022 - Mon
Steve Wales

How about this:

If the column ends in yyyy:

Select max(num) from SomeTable where Date like '%2012'
Member_2_4286571

ASKER
Unfortunately in database date looks like this 2012-10-29 00:00:00.000.

I am using ddMMyyyy in VB.net, but in database is displayed differently.
ASKER CERTIFIED SOLUTION
tim_cs

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Member_2_4286571

ASKER
That's it, thank you.
Your help has saved me hundreds of hours of internet surfing.
fblack61