Convert YYYY-MM-DD to YYYY-MM

2025-01-15 → 2025-01

Quick Converter

2025-01

How to Convert YYYY-MM-DD to YYYY-MM

Converting from YYYY-MM-DD to YYYY-MM involves rearranging the date components:

From
YYYY-MM-DD
2025-01-15
to
YYYY-MM
2025-01
1

Identify the Parts

In YYYY-MM-DD: ISO 8601 standard format, ideal for sorting and international use

2

Rearrange

Reorder to match YYYY-MM format: Year-month format following ISO 8601, ideal for file naming and sorting

3

Adjust Separator

Change the separator from "-" to "-" if needed.

Code Examples

JavaScript
// Convert YYYY-MM-DD to YYYY-MM function convertDate(dateStr) { // Parse YYYY-MM-DD const parts = dateStr.split('-'); const [year, month, day] = parts; // Format as YYYY-MM return `${year}-${month}-${day}`; } console.log(convertDate('2025-01-15')); // 2025-01
Python
from datetime import datetime # Convert YYYY-MM-DD to YYYY-MM date_str = '2025-01-15' date = datetime.strptime(date_str, '%Y-%m-%d') result = date.strftime('%Y-%m-%d') print(result) # 2025-01

Other Conversions

Open Full Converter →

Related Pages