最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

if statement - Excel If and Date function - Stack Overflow

programmeradmin0浏览0评论

=IF(AND(K2>DATEVALUE("30062024"),K2<DATEVALUE("01702026")),"FY 25"),

the above statement returns #Value!, I expect it to return "FY 25" or false

=IF(AND(K2>DATEVALUE("30062024"),K2<DATEVALUE("01702026")),"FY 25"),

Expecting to get "FY 25" for the dates that falls into range or False for the Dates that falls out of range

=IF(AND(K2>DATEVALUE("30062024"),K2<DATEVALUE("01702026")),"FY 25"),

the above statement returns #Value!, I expect it to return "FY 25" or false

=IF(AND(K2>DATEVALUE("30062024"),K2<DATEVALUE("01702026")),"FY 25"),

Expecting to get "FY 25" for the dates that falls into range or False for the Dates that falls out of range

Share Improve this question asked Feb 3 at 9:32 Mwai.JohnMwai.John 275 bronze badges 5
  • 2 Which date range are you comparing. This DATEVALUE("30062024") is producing error. 30062024 is not a valid date value. Datevalue function have to use like =DATEVALUE("01-JAN-2025") or use date function like DATE(2025,1,1). – Harun24hr Commented Feb 3 at 9:35
  • I have a column with different dates (Column K2), and it has date in format of 'd/m/yyyy' – Mwai.John Commented Feb 3 at 10:15
  • 2 Using DATE(2025,1,1) way should solve the error. coz if DATEVALUE("30062024")= 30 June 2024 (considering ddmmyyyy) then what is DATEVALUE("01702026") which month is 70???!!!! – Arya Commented Feb 3 at 10:19
  • @Mwai.John What value do you have in K2 and what is your date range to compare. – Harun24hr Commented Feb 3 at 10:41
  • The first proposal you shared works fine, I have used this format =DATEVALUE("01-JAN-2025")....My challenge was to use SQL format in Excel – Mwai.John Commented Feb 3 at 10:56
Add a comment  | 

1 Answer 1

Reset to default 0

DATEVALUE("30062024") is not valid.

You might try DATEVALUE("30/06/2024"), but this means that your computer (regional settings) is based on the "DD/MM/YYYY" date formatting. In case you have another date formatting (like "YYYY/DD/MM", which is common in the USA), you might need another way to write your formula.

发布评论

评论列表(0)

  1. 暂无评论