pub fn parse_date(
input: &str,
sql_format: &str,
) -> Result<NaiveDate, ExecutorError>Expand description
Parse a date string using SQL format string
ยงExamples
use chrono::NaiveDate;
use vibesql_executor::evaluator::date_format::parse_date;
assert_eq!(
parse_date("2024-03-15", "YYYY-MM-DD"),
Ok(NaiveDate::from_ymd_opt(2024, 3, 15).unwrap())
);
assert_eq!(
parse_date("15/03/2024", "DD/MM/YYYY"),
Ok(NaiveDate::from_ymd_opt(2024, 3, 15).unwrap())
);