Canadian Exchange Rate Calculator by Date

Canadian Exchange Rate Calculator by Date

This calculator helps you determine the exchange rate between the Canadian Dollar (CAD) and another currency on a specific historical date. This is useful for understanding past transaction values, financial reporting, or historical research.

Canadian Dollar (CAD) United States Dollar (USD) Euro (EUR) British Pound (GBP) Japanese Yen (JPY) Australian Dollar (AUD) Chinese Yuan (CNY) United States Dollar (USD) Euro (EUR) British Pound (GBP) Japanese Yen (JPY) Australian Dollar (AUD) Chinese Yuan (CNY) Canadian Dollar (CAD)

function calculateExchangeRate() { var amountToConvert = parseFloat(document.getElementById("amountToConvert").value); var baseCurrency = document.getElementById("baseCurrency").value; var targetCurrency = document.getElementById("targetCurrency").value; var conversionDate = document.getElementById("conversionDate").value; var resultElement = document.getElementById("result"); if (isNaN(amountToConvert)) { resultElement.innerText = "Please enter a valid amount to convert."; return; } if (baseCurrency === targetCurrency) { resultElement.innerText = amountToConvert + " " + baseCurrency + " is equal to " + amountToConvert + " " + targetCurrency + " on " + conversionDate + "."; return; } // This is a mock API call and response. In a real application, you would integrate // with a reliable historical exchange rate API (e.g., ExchangeRate-API, Open Exchange Rates). // The logic below simulates fetching a rate for demonstration purposes. var mockRates = { "2023-01-01": { "CAD_USD": 0.73, "USD_CAD": 1.37, "CAD_EUR": 0.69, "EUR_CAD": 1.45, "CAD_GBP": 0.61, "GBP_CAD": 1.64, "CAD_JPY": 98.00, "JPY_CAD": 0.0102, "CAD_AUD": 1.06, "AUD_CAD": 0.94, "CAD_CNY": 4.96, "CNY_CAD": 0.20 }, "2023-07-15": { "CAD_USD": 0.76, "USD_CAD": 1.32, "CAD_EUR": 0.70, "EUR_CAD": 1.43, "CAD_GBP": 0.62, "GBP_CAD": 1.61, "CAD_JPY": 107.00, "JPY_CAD": 0.0093, "CAD_AUD": 1.11, "AUD_CAD": 0.90, "CAD_CNY": 5.45, "CNY_CAD": 0.18 } // Add more dates and rates as needed for a comprehensive mock }; var selectedRateKey = baseCurrency + "_" + targetCurrency; var ratesForDate = mockRates[conversionDate]; if (ratesForDate && ratesForDate[selectedRateKey] !== undefined) { var exchangeRate = ratesForDate[selectedRateKey]; var convertedAmount = amountToConvert * exchangeRate; resultElement.innerText = amountToConvert + " " + baseCurrency + " was equal to " + convertedAmount.toFixed(2) + " " + targetCurrency + " on " + conversionDate + " (Rate: 1 " + baseCurrency + " = " + exchangeRate + " " + targetCurrency + ")."; } else { resultElement.innerText = "Historical exchange rate data not available for " + conversionDate + " or the selected currency pair. Please try a different date or currency pair."; } } .exchange-rate-calculator { font-family: Arial, sans-serif; padding: 20px; border: 1px solid #ccc; border-radius: 5px; max-width: 600px; margin: 20px auto; background-color: #f9f9f9; } .exchange-rate-calculator h2 { text-align: center; margin-bottom: 20px; color: #333; } .exchange-rate-calculator p { line-height: 1.6; color: #555; } .input-section { margin-bottom: 20px; display: grid; grid-template-columns: 1fr 2fr; gap: 15px; align-items: center; } .input-section label { font-weight: bold; color: #444; } .input-section input[type="number"], .input-section input[type="date"], .input-section select { padding: 10px; border: 1px solid #ccc; border-radius: 4px; width: 100%; box-sizing: border-box; } .input-section button { grid-column: span 2; padding: 12px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } .input-section button:hover { background-color: #45a049; } .result-section { margin-top: 20px; padding: 15px; background-color: #e8f5e9; border: 1px solid #c8e6c9; border-radius: 4px; text-align: center; color: #2e7d32; font-weight: bold; }

Leave a Comment