Skip to main content

format_time_dialect

Function format_time_dialect 

Source
pub fn format_time_dialect(
    format_str: &str,
    source_dialect: Dialect,
    target_dialect: Dialect,
) -> String
Expand description

Convert a time format string from one SQL dialect to another.

This is the main entry point for dialect-to-dialect format conversion.

§Arguments

  • format_str - The format string to convert
  • source_dialect - The source SQL dialect
  • target_dialect - The target SQL dialect

§Returns

The converted format string appropriate for the target dialect.

§Example

use sqlglot_rust::dialects::time::format_time_dialect;
use sqlglot_rust::Dialect;

// Convert MySQL format to PostgreSQL
let result = format_time_dialect("%Y-%m-%d %H:%i:%s", Dialect::Mysql, Dialect::Postgres);
assert_eq!(result, "YYYY-MM-DD HH24:MI:SS");